import React, { PureComponent } from 'react'


class App extends PureComponent {
  render() {
    return (
      <div>
        name: {this.props.name}
        age: {this.props.age}
      </div>
    )
  }
}
//情况一：
function enhanceComponent(WrappedComponent) {
  // es6中，类的表达式中类名是可以省略的
  // return class extends PureComponent {
  //   render() {
  //     return <WrappedComponent />
  //   }
  // }
  //修改 组件名
  class NewComponent extends PureComponent {
    render() {
      return <WrappedComponent {...this.props}/>
    }
  }
  NewComponent.displayName = 'yzh'
  return NewComponent
}
const EnhanceComponent = enhanceComponent(App)

//情况二：
function enhanceComponent2(WrappedComponent) {
  //函数组件
  function NewComponent(props) {
    return <WrappedComponent {...props}/>
  }
  NewComponent.displayName = "Kobe";
  return NewComponent;
}
const EnhanceComponent2 = enhanceComponent2(App);



export default EnhanceComponent